#include <stdio.h> 

int main(){
	int k,a,b,r[1000]={0},i=0;
	scanf("%d %d %d",&k,&a,&b);
	while( a||b ){
		int c=a%10,d=b%10,e=k%10,y=r[i]; if( e==0 ) e=10;
		c+d+r[i]>=e ? r[i]=(c+d+r[i])%e,r[i+1]=(c+d+y)/e:r[i]=c+d+r[i];
		i++;
		a/=10;b/=10;k/=10;
	}
	for( i=1000; r[i]==0; i-- );
	for( ; i>-1; i-- ) printf("%d",r[i]);
	return 0;
} 
